
const moment = require('moment');
const path = require("path");
const fs = require("fs");
var a =(req, res, next) => {
    let time = moment().format("YYYY-MM-DD HH:mm:ss");
    let ip = req.ip;
    let method = req.method;
    let userAgent = req.headers["user-agent"];
    let str = `${time} - ${ip} - ${method} - ${userAgent} \n`;
    let filename = path.join(__dirname, moment().format("YYYYMMDD") + ".txt");
    console.log(__dirname);
    // console.log(filename);
    fs.appendFile(filename, str, err => {
        console.log(err);
        
    });
    next()
    
}
module.exports=a